import Main from '@/views/Main.vue';

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
    path: '/login',
    name: 'login',
    meta: {
        title: 'Login - 登录'
    },
    component: () => import('@/views/login.vue')
};

export const page404 = {
    path: '/*',
    name: 'error-404',
    meta: {
        title: '404-页面不存在'
    },
    component: () => import('@/views/error-page/404.vue')
};

export const page403 = {
    path: '/403',
    meta: {
        title: '403-权限不足'
    },
    name: 'error-403',
    component: () => import('@//views/error-page/403.vue')
};

export const page500 = {
    path: '/500',
    meta: { title: '500-服务端错误' },
    name: 'error-500',
    component: () => import('@/views/error-page/500.vue')
};

export const locking = {
    path: '/locking',
    name: 'locking',
    component: () => import('@/views/main-components/lockscreen/components/locking-page.vue')
};

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
    path: '/',
    name: 'otherRouter',
    redirect: '/home',
    component: Main,
    children: [
        { path: 'home', title: { i18n: 'home' }, name: 'home_index', component: () => import('@/views/home/home.vue') },
        { path: 'ownspace', title: '个人中心', name: 'ownspace_index', component: () => import('@/views/own-space/own-space.vue') },
        { path: 'message', title: '消息中心', name: 'message_index', component: () => import('@/views/message/message.vue') },
        // ------------------------------------------------------------------------------------------------------------------------------
        { path: '/user/detail/:username', title: '用户详情', meta: { title: '用户详情' }, name: 'user-detail', component: () => import('@/views/authority/user-detail.vue') },
        { path: '/roles/detail/:roleName', title: '角色详情', meta: { title: '角色详情' }, name: 'roles-detail', component: () => import('@/views/authority/roles-detail.vue') }
    ]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
    {
        path: '/user',
        icon: 'person',
        title: '用户管理',
        name: 'user',
        component: Main,
        children: [
            { path: 'list', title: '用户管理', meta: { title: '用户管理' }, name: 'user-list', component: () => import('@/views/authority/user-list.vue') }
        ]
    },
    {
        path: '/permission',
        icon: 'android-lock',
        title: '权限管理',
        name: 'permission',
        component: Main,
        children: [
            { path: 'list', title: '权限管理', meta: { title: '权限管理' }, name: 'permission-list', component: () => import('@/views/authority/permission-list.vue') }
        ]
    },
    {
        path: '/roles',
        icon: 'person-stalker',
        title: '角色管理',
        name: 'roles',
        component: Main,
        children: [
            { path: 'list', title: '角色管理', meta: { title: '角色管理' }, name: 'roles-list', component: () => import('@/views/authority/roles-list.vue') }
        ]
    },
    {
        path: '/roles-permission',
        icon: 'toggle-filled',
        title: '角色授权',
        name: 'roles-permission',
        component: Main,
        children: [
            { path: 'list', title: '角色授权', meta: { title: '角色授权' }, name: 'roles-permission-list', component: () => import('@/views/authority/roles-permission.vue') }
        ]
    },
    {
        path: '/user-permission',
        icon: 'toggle-filled',
        title: '用户授权',
        name: 'user-permission',
        component: Main,
        children: [
            { path: 'list', title: '用户授权', meta: { title: '用户授权' }, name: 'user-permission-list', component: () => import('@/views/authority/user-permission.vue') }
        ]
    }
];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
    loginRouter,
    otherRouter,
    locking,
    ...appRouter,
    page500,
    page403,
    page404
];
